[#ftl]
[@define "agile.MetadataEventListenerEditorPane" "agile.MetadataEditorTabPane"]
	category:"event"
	,title:"Event"
	,metadataEntry:"event"
//	,elementConfig:{
//		"onClick":lang.mixin({},agile.EventMetadata,{
//			args:"event"
//		})
//		,"onDbClick":lang.mixin({},agile.EventMetadata,{
//			args:"event"
//		})
//		,"onKeyPress":lang.mixin({},agile.EventMetadata,{
//			args:"event"		
//		})
//		,"onChange":lang.mixin({},agile.EventMetadata,{
//			args:"name,oldValue,newValue"		
//		})
//		,"onLoad":lang.mixin({},agile.EventMetadata,{
//			args:""	
//			,onValueChange:function(widget,name,value){
//				console.log("@@@@@@@@onLoad:",widget,name,value)
//			}
//		})
//	}
//	,constructor:function(){
//		for(var name in this.elementConfig){
//			var cfg = this.elementConfig[name];
//			cfg.name = cfg.label = name;
//			cfg.templateString = lang.replace(cfg.templateString,{name:cfg.name,args:cfg.args});
//		}
//	}	
	,renderEditors:function(widget){	
		//summary:render the event editors (tab pages) dynamically for the widget selected according to the eventConstraints of the widget
		
		//remove existing editors
		array.forEach(this.editorContainer.getChildren(),lang.hitch(this.editorContainer,function(child){
			this.removeChild(child);			
		}));
		
		if(!widget) return;
		
		//reset
		for(var name in this.editorWidgets){				
			this.editorWidgets[name].release();								
		}
		this.editorWidgets = {};
		
		var events = widget.events;
		for(var name in events){
			if(events[name]._ignore) continue;

			var metadata = events[name];				
			var editor = agile.EditorFactory.lookupEditorWidget(metadata,this);
			//lang.mixin(this.editorWidgets,editor.getEditors());
			this.editorWidgets[name] = editor;
			var child = new ContentPane({title:metadata.label,content:editor,closable:false
//					,onClose:function(parent,tab){
//						parent.removeChild(tab);
//						return false;
//					}
			});
			this.editorContainer.addChild(child);
		}			
	}

,setEditorValue:function(widget){		
//	console.log(this.declaredClass,"setEditorValue.....event=",widget.metadata(this.metadataEntry));
	for (var name in this.editorWidgets){
//		console.log("1###########reset1",name,widget.metadata(this.metadataEntry));
		this.editorWidgets[name].reset1("value",widget.metadata(this.metadataEntry));
	}		
}

[/@] 
